const CryptoJS = require('crypto-js');

export function aesEncrypt(data, key) {
  //console.log("data:"+data);
  key = CryptoJS.enc.Utf8.parse(key);
  var srcs = CryptoJS.enc.Utf8.parse(data);
  var encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
  //console.log("data后:"+encrypted.toString());
  var a = encrypted.toString();
  //console.log("data后:"+encrypted.toString());
  let b = new RegExp("/", "g");
  let c = new RegExp("\\+", "g");
  a = a.replace(b, "$").replace(c, "*");
  return a;
}

export function SSAaesEncrypt(data, key) {
  //console.log("data:"+data);
  key = CryptoJS.enc.Utf8.parse(key);
  var srcs = CryptoJS.enc.Utf8.parse(data);
  var encrypted = CryptoJS.AES.encrypt(srcs, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
  //console.log("data后:"+encrypted.toString());
  var a = encrypted.toString();
  return a;
}
